<!DOCTYPE HTML>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <form th:id="form-data" th:action="@{/banner/add}" th:object="${banner}" method="post">
                <div class="panel-body">
                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">序号</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{sequence}" maxlength="120" onfocus="clearErrorMsg()" placeholder="请输入序号" />
                        </div>
                    </div>

                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">是否使用</label>
                        <div class="col-sm-4 col-sm-inp">
                            <select class="form-control" th:field="*{isUse}">
                                <option th:value="true">是</option>
                                <option th:value="false">否</option>
                            </select>
                        </div>
                    </div>

                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">链接</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="text" class="form-control" th:field="*{link}" maxlength="120" onfocus="clearErrorMsg()" placeholder="请输入banner链接" />
                        </div>
                    </div>

                    <div class="form-group clear">
                        <label class="col-sm-1 control-label search-label">Banner</label>
                        <div class="col-sm-4 col-sm-inp">
                            <input type="hidden" th:field="*{url}" class="text-input " value=""/>
                            <input style="display: none;" type="file" id="fileUpload" name="fileUpload">
                            <input type="button" class="button" id="upload" onclick="uploadFile();" value="上传">
                            <img id="img-preview" alt="图片预览" style="height: 100px; width: 200px;" th:src="#{client.base.url} + *{url}" /><br/>
                            <p style="color:#A9A9A9; ">请上传750* 400大小的图片</p>
                        </div>
                    </div>

                    <div th:if="${editType == 'EDIT'}">
                        <input th:type="hidden" th:field="*{id}" placeholder=""/>
                    </div>
                    <input th:type="hidden" id="editType" name="editType" th:value="${editType}" placeholder="">

                    <div class="clear errorMsg" id="errorMsg"></div>

                    <div class="panel-heading">
                        <div>
                            <button type="button" class="btn btn-sm btn-warning"
                                    th:onclick="'javascript:loadListData(\'' + @{/banner/list} + '\')'">返回</button>&emsp;
                            <button type="button" class="btn btn-sm btn-success" onclick="checkParams()">确定</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script th:src="@{/manager/js/banner.js}"></script>
<script th:src="@{/common/js/jquery.upload.js}"></script>
<script th:inline="javascript">
    function uploadFile() {
        upload(function(data) {
            $("#url").val(data);
            $("#img-preview").attr("src", basePath + data);
        }, basePath);
    }
</script>
</html>
